﻿namespace Sidvall.IdentityManager.Net.SimpleServices.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class UserConfiguration : global::Sidvall.Data.SimpleServiceDataRowBase, global::Sidvall.IdentityManager.Data.IUserConfiguration
    {
        #region Public Members

        #region ConfirmationEmailBody

        private string _ConfirmationEmailBody;
        public string ConfirmationEmailBody
        {
            get
            {
                return _ConfirmationEmailBody;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ConfirmationEmailBody, value))
                    return;
                _ConfirmationEmailBody = value;
                OnPropertyChanged(nameof(ConfirmationEmailBody), true);
            }
        }

        #endregion
        #region ConfirmationEmailFromAddress

        private string _ConfirmationEmailFromAddress;
        public string ConfirmationEmailFromAddress
        {
            get
            {
                return _ConfirmationEmailFromAddress;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ConfirmationEmailFromAddress, value))
                    return;
                _ConfirmationEmailFromAddress = value;
                OnPropertyChanged(nameof(ConfirmationEmailFromAddress), true);
            }
        }

        #endregion
        #region ConfirmationEmailSubject

        private string _ConfirmationEmailSubject;
        public string ConfirmationEmailSubject
        {
            get
            {
                return _ConfirmationEmailSubject;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ConfirmationEmailSubject, value))
                    return;
                _ConfirmationEmailSubject = value;
                OnPropertyChanged(nameof(ConfirmationEmailSubject), true);
            }
        }

        #endregion
        #region DefaultServerItemId

        private int _DefaultServerItemId;
        public int DefaultServerItemId
        {
            get
            {
                return _DefaultServerItemId;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_DefaultServerItemId, value))
                    return;
                _DefaultServerItemId = value;
                OnPropertyChanged(nameof(DefaultServerItemId), true);
            }
        }

        #endregion
        #region Name

        private string _Name;
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_Name, value))
                    return;
                _Name = value;
                OnPropertyChanged(nameof(Name), true);
            }
        }

        #endregion
        #region PluginPath

        private string _PluginPath;
        public string PluginPath
        {
            get
            {
                return _PluginPath;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_PluginPath, value))
                    return;
                _PluginPath = value;
                OnPropertyChanged(nameof(PluginPath), true);
            }
        }

        #endregion
        #region ResetPasswordEmailBody

        private string _ResetPasswordEmailBody;
        public string ResetPasswordEmailBody
        {
            get
            {
                return _ResetPasswordEmailBody;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ResetPasswordEmailBody, value))
                    return;
                _ResetPasswordEmailBody = value;
                OnPropertyChanged(nameof(ResetPasswordEmailBody), true);
            }
        }

        #endregion
        #region ResetPasswordEmailFromAddress

        private string _ResetPasswordEmailFromAddress;
        public string ResetPasswordEmailFromAddress
        {
            get
            {
                return _ResetPasswordEmailFromAddress;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ResetPasswordEmailFromAddress, value))
                    return;
                _ResetPasswordEmailFromAddress = value;
                OnPropertyChanged(nameof(ResetPasswordEmailFromAddress), true);
            }
        }

        #endregion
        #region ResetPasswordEmailSubject

        private string _ResetPasswordEmailSubject;
        public string ResetPasswordEmailSubject
        {
            get
            {
                return _ResetPasswordEmailSubject;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ResetPasswordEmailSubject, value))
                    return;
                _ResetPasswordEmailSubject = value;
                OnPropertyChanged(nameof(ResetPasswordEmailSubject), true);
            }
        }

        #endregion
        #region ShowNewsAtStartup

        private bool _ShowNewsAtStartup;
        public bool ShowNewsAtStartup
        {
            get
            {
                return _ShowNewsAtStartup;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ShowNewsAtStartup, value))
                    return;
                _ShowNewsAtStartup = value;
                OnPropertyChanged(nameof(ShowNewsAtStartup), true);
            }
        }

        #endregion
        #region SmtpServer

        private string _SmtpServer;
        public string SmtpServer
        {
            get
            {
                return _SmtpServer;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_SmtpServer, value))
                    return;
                _SmtpServer = value;
                OnPropertyChanged(nameof(SmtpServer), true);
            }
        }

        #endregion
        #region StartPageId

        private global::Sidvall.IdentityManager.Data.PageType _StartPageId;
        public global::Sidvall.IdentityManager.Data.PageType StartPageId
        {
            get
            {
                return _StartPageId;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_StartPageId, value))
                    return;
                _StartPageId = value;
                OnPropertyChanged(nameof(StartPageId), true);
            }
        }

        #endregion
        #region UserConfigurationId

        private System.Nullable<int> _UserConfigurationId;
        public System.Nullable<int> UserConfigurationId
        {
            get
            {
                return _UserConfigurationId;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_UserConfigurationId, value))
                    return;
                _UserConfigurationId = value;
                OnPropertyChanged(nameof(UserConfigurationId), true);
            }
        }

        #endregion
        
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public ServerItemCollection ServerItems { get; set; }
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.LoadInstanceField(this, fieldName, value, cascade, false, false);
        }

        #endregion
        #region Copy

        public UserConfiguration Copy()
        {
            return global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Copy(this);
        }
        public UserConfiguration Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.IdentityManager.Data.IUserConfiguration item)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Import(this, item);
        }
        public void Import(global::Sidvall.IdentityManager.Data.IUserConfiguration item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Import(this, item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Initialize(this, settings);
        }

        #endregion

        #region IUserConfiguration Members

        string global::Sidvall.IdentityManager.Data.IUserConfiguration.ConfirmationEmailBody
        {
            get
            {
                return this._ConfirmationEmailBody;
            }
            set
            {
                this._ConfirmationEmailBody = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.ConfirmationEmailFromAddress
        {
            get
            {
                return this._ConfirmationEmailFromAddress;
            }
            set
            {
                this._ConfirmationEmailFromAddress = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.ConfirmationEmailSubject
        {
            get
            {
                return this._ConfirmationEmailSubject;
            }
            set
            {
                this._ConfirmationEmailSubject = value;
            }
        }
        int global::Sidvall.IdentityManager.Data.IUserConfiguration.DefaultServerItemId
        {
            get
            {
                return this._DefaultServerItemId;
            }
            set
            {
                this._DefaultServerItemId = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this._Name = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.PluginPath
        {
            get
            {
                return this._PluginPath;
            }
            set
            {
                this._PluginPath = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.ResetPasswordEmailBody
        {
            get
            {
                return this._ResetPasswordEmailBody;
            }
            set
            {
                this._ResetPasswordEmailBody = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.ResetPasswordEmailFromAddress
        {
            get
            {
                return this._ResetPasswordEmailFromAddress;
            }
            set
            {
                this._ResetPasswordEmailFromAddress = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.ResetPasswordEmailSubject
        {
            get
            {
                return this._ResetPasswordEmailSubject;
            }
            set
            {
                this._ResetPasswordEmailSubject = value;
            }
        }
        bool global::Sidvall.IdentityManager.Data.IUserConfiguration.ShowNewsAtStartup
        {
            get
            {
                return this._ShowNewsAtStartup;
            }
            set
            {
                this._ShowNewsAtStartup = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IUserConfiguration.SmtpServer
        {
            get
            {
                return this._SmtpServer;
            }
            set
            {
                this._SmtpServer = value;
            }
        }
        global::Sidvall.IdentityManager.Data.PageType global::Sidvall.IdentityManager.Data.IUserConfiguration.StartPageId
        {
            get
            {
                return this._StartPageId;
            }
            set
            {
                this._StartPageId = value;
            }
        }
        System.Nullable<int> global::Sidvall.IdentityManager.Data.IUserConfiguration.UserConfigurationId
        {
            get
            {
                return this._UserConfigurationId;
            }
            set
            {
                this._UserConfigurationId = value;
            }
        }
        System.Collections.Generic.IEnumerable<global::Sidvall.IdentityManager.Data.IServerItem> global::Sidvall.IdentityManager.Data.IUserConfiguration.ServerItems
        {
            get
            {
                if (this.ServerItems != null)
                    return this.ServerItems;
                return null;
            }
        }
        void global::Sidvall.IdentityManager.Data.IUserConfiguration.SetServerItems(Sidvall.Data.IDataRowProvider<global::Sidvall.IdentityManager.Data.IServerItem> items)
        {
            this.ServerItems = (ServerItemCollection)items;
        }

        #endregion

        #endregion
        #region Constructors

        public UserConfiguration()
        {
        }
        public UserConfiguration(bool initializeDefaultValues)
        {
            if (initializeDefaultValues)
                global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.UserConfigurationManager.Initialize(this);
        }

        #endregion
    }
}